#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 29 17:19:50 2025

@author: ulyanov
"""

from game import Game
from map_selector import MapSelector

if __name__ == "__main__":
    running = True
    selected_map = None
    
    while running:
        # 如果没有选择地图，显示地图选择界面
        if not selected_map:
            selector = MapSelector()
            selected_map = selector.run()
            
            # 如果用户关闭了地图选择窗口，退出游戏
            if not selected_map:
                running = False
                break
        
        # 启动游戏并传入所选地图
        game = Game(selected_map)
        result = game.run()
        
        # 根据游戏返回结果进行处理
        if result == "select_map":
            selected_map = None  # 清空已选地图，将重新显示选择界面
        elif result == "quit":
            running = False  # 退出游戏